package com.hehe.controller;


import com.hehe.Dao.Test_Mapper;
import com.hehe.POJO.Tb_search;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;




@Controller
@RequestMapping(value="/ajax")
public class Select {

    @Autowired
    private Test_Mapper test_mapper;
    

    // ResponseBody 自动将对象转 json
    @GetMapping(value="/ajaxAutoComplete/{keyword}" )
    @ResponseBody
    public List<Tb_search> get_All(Model model, @PathVariable String keyword){
        System.out.println(keyword);
        System.out.println(keyword);
        System.out.println("访问 ajaxAutoComplete 啦 ~ !!!");
        System.out.println(" ==============  数据库查询中 ================    ");
        List<Tb_search> all = test_mapper.search(keyword);
        return all;
    }


}




